package com.yeskery.nut.extend.mcp.server;

import com.yeskery.nut.core.Controller;
import com.yeskery.nut.core.Execution;
import com.yeskery.nut.core.Request;
import com.yeskery.nut.core.Response;

/**
 * HTTP MCP消息请求Controller
 * @author sprout
 * 2025-04-21 11:05
 */
public class HttpMcpMessageController implements Controller {

    /** MCP消息请求处理 */
    private final HttpMcpMessageRequestHandler httpMcpMessageRequestHandler;

    /**
     * 构造函数
     * @param httpMcpMessageRequestHandler MCP消息请求处理
     */
    public HttpMcpMessageController(HttpMcpMessageRequestHandler httpMcpMessageRequestHandler) {
        this.httpMcpMessageRequestHandler = httpMcpMessageRequestHandler;
    }

    @Override
    public void doGet(Request request, Response response, Execution execution) {
        response.writeEmpty();
    }

    @Override
    public void doPost(Request request, Response response, Execution execution) {
        httpMcpMessageRequestHandler.handle(request, response, execution);
    }
}
